<?php
namespace Lib;
class Translit{
    public static $CHAR_TABLE = array(
		   "Ґ"=>"G","Ё"=>"YO","Є"=>"E","Ї"=>"YI","І"=>"I",
		   "і"=>"i","ґ"=>"g","ё"=>"yo","№"=>"#","є"=>"e",
		   "ї"=>"yi","А"=>"A","Б"=>"B","В"=>"V","Г"=>"G",
		   "Д"=>"D","Е"=>"E","Ж"=>"ZH","З"=>"Z","И"=>"I",
		   "Й"=>"Y","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N",
		   "О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T",
		   "У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"TS","Ч"=>"CH",
		   "Ш"=>"SH","Щ"=>"SCH","Ъ"=>"'","Ы"=>"YI","Ь"=>"",
		   "Э"=>"E","Ю"=>"YU","Я"=>"YA","а"=>"a","б"=>"b",
		   "в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"zh",
		   "з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l",
		   "м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r",
		   "с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h",
		   "ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"'",
		   "ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya"
		  );

    public static $CHAR_STRIP_BEFORE = array();
	public static $CHAR_STRIP_AFTER = array();

	public static $CHAR_FILTERS = array(
	    ' '=>'-'
	);
	
	public function __construct(){}
	
    public static function translit($string, $charTable, $charFilters = array(), $charStripBefore = array(), $charStripAfter = array(), $fromLang = 'ru', $toLang = 'en'){
        if($tmpRes = self::_getFromCache($string, $fromLang, $toLang)){
            return $tmpRes;
        }
        $string = str_replace($charStripBefore, '', $string);
        $string = strtr($string,$charTable);
        $string = str_replace($charStripAfter, '', $string);
        $string = strtr($string,$charFilters);
        
        self::_saveToCache($string, $fromLang, $toLang);
        
        return $string;
    }
    
    /**
     * @todo Need to implement
     * Enter description here ...
     * @param unknown_type $string
     * @param unknown_type $fromLang
     * @param unknown_type $toLang
     */
    private static function _getFromCache($string, $fromLang, $toLang){
        return false;
    }
    
    /**
     * @todo Need to implement
     * Enter description here ...
     * @param unknown_type $string
     * @param unknown_type $fromLang
     * @param unknown_type $toLang
     */
    private static function _saveToCache($string, $fromLang, $toLang){
        return false;
    }
}